package com.nwpu.server.search.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.nwpu.server.search.entity.GeneDiseaseAssociationEntity;
import com.nwpu.server.search.service.GeneDiseaseAssociationService;
import com.nwpu.server.common.response.*;



/**
 *
 *
 * @author YuXingZh
 * @email 617058979@qq.com
 * @date 2022-04-10 11:27:38
 */
@RestController
@RequestMapping("search/genediseaseassociation")
public class GeneDiseaseAssociationController {
    @Autowired
    private GeneDiseaseAssociationService geneDiseaseAssociationService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = geneDiseaseAssociationService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{diseaseid}")
    public R info(@PathVariable("diseaseid") String diseaseid){
		GeneDiseaseAssociationEntity geneDiseaseAssociation = geneDiseaseAssociationService.getById(diseaseid);

        return R.ok().put("geneDiseaseAssociation", geneDiseaseAssociation);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody GeneDiseaseAssociationEntity geneDiseaseAssociation){
		geneDiseaseAssociationService.save(geneDiseaseAssociation);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody GeneDiseaseAssociationEntity geneDiseaseAssociation){
		geneDiseaseAssociationService.updateById(geneDiseaseAssociation);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody String[] diseaseids){
		geneDiseaseAssociationService.removeByIds(Arrays.asList(diseaseids));

        return R.ok();
    }

}
